<?php

namespace app\admin\controller;

use think\Controller;
use think\Session;
use app\common\controller\Auth;

class Index extends Controller
{
    /**
     * 后台首页
     * @return \think\response\View
     * @throws \think\Exception
     */
    public function index()
    {
        $lang=input('lang');
        switch ($lang) {
            case 'en':
                cookie('think_var', 'en');
                break;
            case 'zn':
                cookie('think_var', 'zh-cn');
                break;
            default:
                cookie('think_var','zh-cn');
                break;
        }

        $loginStatus = Session::get('userinfo');

        if (!$loginStatus) {
            return view('login');
        }

        $rules = Auth::instance()->groupId(session('userinfo.role_id'))->rules(['test1','test2'])->vif();
//        dump($rules);die;
        $menu = Auth::instance()->groupId(session('userinfo.role_id'))->getMenu();
        $this->assign('menuList', $menu);
        return view('index');
        
    }

    public function hello()
    {
        echo ':)';
    }
}
